//
//  NSString+Category.m
//  game
//
//  Created by yun on 2018/3/12.
//  Copyright © 2018年 YD. All rights reserved.
//

#import "NSString+Category.h"

@implementation NSString (Category)

- (NSMutableAttributedString *)changeAttributeStringWithSubstringArray:(NSArray *)substringArray
                                                                   color:(UIColor *)color
                                                                font:(UIFont *)font {
    
    NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:self];
    
    for (NSString *substring in substringArray) {
        
        NSRange range = [self rangeOfString:substring];
        [attributeString addAttribute:NSForegroundColorAttributeName value:color range:range];
        [attributeString addAttribute:NSFontAttributeName value:font range:range];
    }
    
    return attributeString;
}

@end
